<template>
  <div class="dashboard-container">
    <div class="dashboard-text">{{ this.username }}</div>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'
import {getInfo} from "@/api/user";

export default {
  name: 'Dashboard',
  data() {
    return {
      username: ''
    }
  },
  methods: {
    getUserInfo() {
      getInfo().then(res => {
        if (res.data.role === 1) {
          this.username = '欢迎' + res.data.username.substring(0, 1) + '总光临系统'
        }
        if (res.data.role === 0) {
          this.username = '欢迎' + res.data.username.substring(0, 1) + res.data.jobTitle + '光临系统,宁康医疗为您的健康保驾护航'
        }
      })
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'jobTitle'
    ])
  },
  created() {
    this.getUserInfo()
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }

  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
